package com.zhentao.controller;

import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.common.pojo.coupon.cdzdtos.ComputeAmountDto;
import com.zhentao.model.common.pojo.coupon.cdzdtos.CouponDTO;
import com.zhentao.service.ICdzUserCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mp
 * @since 2024-12-18
 */
@RestController
@RequestMapping("/market/api/user/coupon")
public class CdzUserCouponController {
    @Autowired
    private ICdzUserCouponService cdzUserCouponService;
    @PostMapping("/list")
    /**
     * @description: 查询可以使用的优惠卷
     * @author: muhaoyang 
     * @date: 2024/12/26 14:53
     * @param: [couponDTO]
     * @return: com.zhentao.model.common.dtos.ResponseResult
     **/
    public ResponseResult list(@RequestBody CouponDTO couponDTO){
        return  cdzUserCouponService.listwd(couponDTO);
    }

    @PostMapping("/ids/coupon/amount")
    public ResponseResult computeAmount(@RequestBody ComputeAmountDto computeAmountDto){
        return cdzUserCouponService.computeAmount(computeAmountDto);
    }

    @DeleteMapping("/delete/user/coupon")
    public ResponseResult deleteUserCoupon(@RequestParam("couponId") List<Integer> couponIds , @RequestParam("userId") Long userId){
        return cdzUserCouponService.deleteUserCoupon(couponIds,userId);
    }
}
